<template>
	<view class="div">
		<view class="flet">
			<van-sidebar   active-key=" 0 ">
		  <van-sidebar-item @click="Button(item.bcid)" v-for="item in taBar[0]" :key="item.bcid"  :title="item.name" />
		 

		</van-sidebar>
		</view>
		
		<view class="right">
			<van-card
			
			@tap="ahntopage(item.objectId)"
		v-for="item in selectlist"
		  :key="item.objectId"
		  
		  :desc="item.name"
		  :title="item.title"
		  :thumb="item.imageurl"
		></van-card>
		
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				 
				 taBar:[],
				 list:[],
				 selectlist:[]
			}
		},
		onShow() {
			this.data()
			
		},
		onLoad() {
			this.pcclass()
		},
		
		methods: {
			pcclass(){
				let url = `/1.1/classes/pcclass`
				this.$get(url).then(res => {
					this.taBar.push(res.results)
					console.log(res.results)
				})
				
				console.log(this.taBar)
			},
			data(){
				let url=`/1.1/classes/ouyiclass`
					this.$get(url).then(res=>{
						uni.stopPullDownRefresh()
						// console.log(res)
						let {results}=res
						if(results.length){
							// this.list=this.list.concat(res.results)
							// return
							
							
								this.selectlist=res.results
								this.list=res.results
							
						}
						// console.log(this.list)
					})
					
			},
			Button(bcid){
				console.log(bcid)
				this.selectlist=''
				if(bcid== 0)
				{
					this.selectlist=this.list
				}
				else{
					
				this.selectlist =this.list.filter(item =>{
					// console.log(item.bcid.includes(bcid))
					if (item.bcid_class && item.bcid_class.includes(bcid)) {
					    return item.bcid_class.includes(bcid)
					  }
					  console.log("没数据")
					
					
				})
				
				}
				
				console.log(this.selectlist)
				
			},
			ahntopage(item){
				// console.log("点击事件出发了")
				
				
		
				  // 用户已经登录，执行相关操作
				  // console.log("一登陆")
				 uni.navigateTo({
				 	url:`../flzhanshi/flzhanshi?id=`+item
				 })
				  
				
				
				
			}
		},
		
	}
</script>

<style>
	.div{
		display: flex;
	}
.right{
	width: 350px;
	
	border: 1px solid black;
	margin-left: 83px;
}
.flet{
	width: 80px;
	border: 1px solid black;
	position: fixed;
	
}
</style>
